<!--全局回复源代码弹窗-->
<script setup>

import ClickCopy from "@/components/common/click-copy.vue";

import GlobalDialog from "@/components/common/dialog/GlobalDialog.vue";
import {unEscape} from "@ginstone/common-utils/dist/src/utils/StrUtils";
import {useStore} from "vuex";

// 弹窗名称
const name = 'bbsCode'

const store = useStore();
const closeDialog = (payload) => store.commit("Dialog/closeDialog", payload)
const getCode = (data) => {
  return unEscape(data.replace(/<br\/*>/g, "\n"))
}

</script>

<template>
  <global-dialog :name="name">
    <template #default="{data}">
      <el-scrollbar max-height="600" style="white-space: pre;">
        {{ getCode(data) }}
      </el-scrollbar>
    </template>
    <template #header="{data}">
      <h4 style="margin-top: 0;margin-bottom: 0">源代码 -
        <click-copy :text="getCode(data)" @success="closeDialog(name)">
          <el-button size="small" type="primary">复制全部</el-button>
        </click-copy>
      </h4>
    </template>
  </global-dialog>
</template>

<style scoped>

</style>